<template>
  <div id="top-header">
    <dv-decoration-8 class="header-left-decoration" />
    <dv-decoration-5 class="header-center-decoration" />
    <dv-decoration-8 class="header-right-decoration" :reverse="true" />

    <div class="center-title">
      <div>出荷作业进度看板</div>
      <span class="timing">{{ timing }}</span>
    </div>

  </div>
</template>

<script>
export default {
  name: 'TopHeader',
  data() {
    return {
      timing: undefined,
      dateDay: undefined,
      dateYear: undefined,
      dateWeek: undefined
    }
  },
  created() {
    this.timing = setInterval(() => {
      const now = new Date();
      this.timing = this.formatTime(now)
    }, 1000)
  },
  methods: {
    formatTime(date) {
      const [year, month, day, hours, minutes, seconds] =
        [date.getFullYear(), date.getMonth() + 1, date.getDate(),
          date.getHours(), date.getMinutes(), date.getSeconds()];
      return `${year}-${month.toString().padStart(2, '0')}-${day.toString().padStart(2, '0')} ` +
           `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
    }
  }
}
</script>

<style lang="less" scoped>
#top-header {
  position: relative;
  width: 100%;
  height: 12vh;
  display: flex;
  justify-content: space-between;
  flex-shrink: 0;

  .header-center-decoration {
    width: 40%;
    height: 60px;
    margin-top: 50px;
  }

  .header-left-decoration, .header-right-decoration {
    width: 25%;
    height: 60px;
  }

  .center-title {
    position: absolute;
    font-size: 30px;
    font-weight: bold;
    left: 50%;
    top: 10px;
    text-align: center;
    transform: translateX(-50%);
  }
  .timing {
      font-size: 16px;
      text-align: center;
    }
}
</style>
